from django.contrib import admin
from .models import Question , Choice, Flight,FlightGroundGuardJob
from django.contrib.admin import AdminSite
# Register your models here.

class CustomAdminSite(AdminSite):
    site_header="MyApp Administration"
    site_title="MySite"
    index_title="Just Love Angel"

# parent class may be admin.StackedInline or admin.TabularInline
class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class QuestionAdmin(admin.ModelAdmin):
    #fields= [ 'pub_date', 'question_text']
    list_filter=['pub_date']
    search_fields = ['question_text']
    list_display=('question_text','pub_date',"was_published_recently")
    fieldsets = [
        (None, {'fields':['question_text'],}),
        ('Date Information', {'fields':['pub_date'], 'classes':['collapse'],}),
    ]

    inlines = [ChoiceInline]

class FlightAdmin(admin.ModelAdmin):
    list_filter=['flight_no']
    search_fields=['flight_no']
    list_display=('flight_no','airline','airport_from','airport_to', \
        'expected_takeoff_time','expected_arrival_time', \
        'actual_takeoff_time','actual_arrival_time')

class FlightGroundGuardJobAdmin(admin.ModelAdmin):
    list_filter=['Job_Type']

admin_site = CustomAdminSite(name='myadmin')
admin_site.register(Question,QuestionAdmin)
admin_site.register(Choice)
admin_site.register(Flight,FlightAdmin)
admin_site.register(FlightGroundGuardJob,FlightGroundGuardJobAdmin)
#admin.site.register(Question,QuestionAdmin)
#admin.site.register(Choice)
